import { createApp } from 'vue'
import App from './App'
import router from "./router/index";
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/reset.css';
import i18n from './lang'
import 'animate.css';

const app = createApp(App);
app.use(router);
app.use(Antd);
app.use(i18n);
app.directive('animate', {
    mounted: (el, binding) => {
        const scrollHandler = () => {
            const rect = el.getBoundingClientRect();
            if (rect.top >= 0 && rect.bottom <= window.innerHeight) {
                // 在视口中，执行动画
                el.classList.add(...binding.value.split(' '));
            }
        };

        window.addEventListener('scroll', scrollHandler);

        // 清理函数，防止内存泄漏
        return () => {
            window.removeEventListener('scroll', scrollHandler);
        };
    },
});
app.mount('#app')
